export default class Rendergood {
    str='';
    item;
    constructor(select) 
    {
        this.box = document.getElementById(select);

        this.pfetch();
        
    }

    async pfetch(start,end) {

        fetch("http://localhost:4022/prolist").then(res => res.json())
            .then(res => {
                this.item=res;
                this.render(this.item,start,end);
            })
          
            // console.log(this.item);
    }
    render(res,start,end){
        for(var i=start;i<=end;i++){
            this.str+=`<ul class="lis">
                        <li class="border" >
                            <a rel="nofollow" href="./details.html#id=${res[i].proID}" >
                                <img src="${res[i].src}">
                                <div class="proinfo">
                                    <div class="row" style="flex-wrap: wrap; overflow: hidden; height: 26px;">
                                        <strong class="price">￥${res[i].price}</strong>
                                        <span class="targ">直降${res[i].no_price - res[i].price}元</span>
                                        <span class="targ">包邮</span>
                                        <span class="targ">货到付款</span>
                                    </div>
                                    <h3>${res[i].title}</h3>
                                    <div class="num">
                            
                                        <span>${res[i].no_price * 10}个好评</span>
                                    </div>
                                </div>
                            </a>
                            <div class="inner"></div>
                        </li>
                    </ul>`
                            }
                            this.box.innerHTML=this.str;
                        }


}
